package net.mysoft.budgetsoft.system.service.impl;

import net.mysoft.budgetsoft.system.dao.UserDao;
import net.mysoft.budgetsoft.system.domain.TUser;
import net.mysoft.budgetsoft.system.service.LoginService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * 登陆service
 * @author kangrui
 *
 */
@Service("loginService")
public class LoginServiceImpl implements LoginService{
	
	@Autowired
	private UserDao userDao;

	@Override
	public TUser check(String name, String pwd) {
		return userDao.get("from TUser u where u.loginName = ? and u.pwd = ?", 
				new Object[]{name, new Md5PasswordEncoder().encodePassword(pwd, null)});
	}

}
